use const_primes::is_prime;

struct PrimeMatrix {
    n: u128,           // 矩阵大小
    prime: Vec<u128>,  // 素数
    matrix: Vec<u128>, // 对角线
}

impl PrimeMatrix {
    fn new() -> PrimeMatrix {
        PrimeMatrix {
            n: 1,
            prime: vec![],
            matrix: vec![1],
        }
    }

    fn caculate_matrix(&mut self) -> f32 {
        let mut new_vec = Vec::new();
        for i in 1..=4 {
            new_vec.push(self.n * self.n + (self.n + 1) * i);
        }
        for num in new_vec.iter() {
            if is_prime(*num as u64) {
                self.prime.push(*num);
            }
            self.matrix.push(*num);
        }
        self.n += 2;

        (self.prime.len() as f32 / self.matrix.len() as f32) * 100.0
    }
}

pub fn min_edge_prime_num(number: u32) -> String {
    let mut prime = PrimeMatrix::new();
    while prime.caculate_matrix() > number as f32 {}
    format!("{},{}", prime.n, prime.prime.len())
}
